﻿@model IFDB.ViewModels.PartialViewModels.PersonAppearancesViewModel

<div class="PersonListTable">
    @foreach (var group in Model.PersonCareerList.GroupBy(item => item.Team))
    {
        foreach (var item in group.Take(1))
        {
            using (var mainAccordion = Html.JQueryUI().Begin(new Accordion().HeightStyle(HeightStyle.Content).Active(0).Collapsible(true, false)))
            {
                using (mainAccordion.BeginPanel(item.Team.TeamName))
                {
                    <table class="TeamPersonList">
                        <tr>
                            <th></th>
                            <th style="text-align:center; vertical-align: middle;">
                                <img style="height: 20px" src="~/Content/images/played.png" alt="Appearances" title="Appearances" />
                            </th>
                            <th style="text-align:center; vertical-align: middle;">
                                <img style="height: 20px" src="~/Content/images/goal.png" alt="Goals" title="Goals" />
                            </th>
                            <th style="text-align:center; vertical-align: middle;">
                                <img style="height: 20px" src="~/Content/images/yellowcard.png" alt="Yellow cards" title="Yellow cards" />
                            </th>
                            <th style="text-align:center; vertical-align: middle;">
                                <img style="height: 20px" src="~/Content/images/redcard.png" alt="Red cards" title="Red cards" />
                            </th>
                        </tr>
                
                        @foreach (var season in Model.PersonCareerList.Where(p => p.Team == item.Team))
                        {
                            <tr>
                                <td class="Person">@Html.ActionLink(item.Season.SeasonName, "Index", "Person", new { personId = Model.Person.PersonId, seasonId = item.Season.SeasonId }, null)</td>
                                <td class="PersonStat">@(item.Started + item.UsedSubstitute)</td>
                                <td class="PersonStat">@item.Goals</td>
                                <td class="PersonStat">@item.YellowCards</td>
                                <td class="PersonStat">@item.RedCards</td>
                            </tr>
                        }

                    </table>
                }
            }
        }
    }
</div>